/// Returns the appropriate output directory for the specified package and
/// target.
pub fn out_dir(&self, unit: &Unit) -> PathBuf {
- self.layout(unit.pkg, unit.kind).out_dir(unit.pkg, unit.target)
+ if unit.profile.doc {
+ self.layout(unit.pkg, unit.kind).doc_root()
+ } else {
+ self.layout(unit.pkg, unit.kind).out_dir(unit.pkg, unit.target)
+ }
}
/// Return the (prefix, suffix) pair for dynamic libraries.
let root = cx.out_dir(unit);
let mut missing_outputs = false;
- if !unit.profile.doc {
+ if unit.profile.doc {
+ missing_outputs = !root.join(unit.target.crate_name())
+ .join("index.html").exists();
+ } else {
for filename in try!(cx.target_filenames(unit)).iter() {
missing_outputs |= fs::metadata(root.join(filename)).is_err();
}
self.root().to_path_buf()
}
}
+
+ pub fn doc_root(&self) -> PathBuf {
+ // the "root" directory ends in 'debug' or 'release', and we want it to
+ // end in 'doc' instead
+ self.root.root().parent().unwrap().join("doc")
+ }
}
rustdoc.arg("--target").arg(target);
}
- // the "root" directory ends in 'debug' or 'release', and we want it to end
- // in 'doc' instead
- let doc_dir = cx.layout(unit.pkg, unit.kind).proxy().root();
- let doc_dir = doc_dir.parent().unwrap().join("doc");
+ let doc_dir = cx.out_dir(unit);
// Create the documentation directory ahead of time as rustdoc currently has
// a bug where concurrent invocations will race to create this directory if
use std::str;
+use std::fs;
use support::{project, execs, path2url};
use support::{COMPILING, DOCUMENTING, RUNNING};
assert_that(&p.root().join("target/doc/foo/fn.foo.html"), existing_file());
assert_that(&p.root().join("target/doc/bar/fn.bar.html"), existing_file());
});
+
+test!(rerun_when_dir_removed {
+ let p = project("foo")
+ .file("Cargo.toml", r#"
+ [package]
+ name = "foo"
+ version = "0.0.1"
+ authors = []
+ "#)
+ .file("src/lib.rs", r#"
+ /// dox
+ pub fn foo() {}
+ "#);
+ assert_that(p.cargo_process("doc"),
+ execs().with_status(0));
+ assert_that(&p.root().join("target/doc/foo/index.html"), existing_file());
+
+ fs::remove_dir_all(p.root().join("target/doc/foo")).unwrap();
+
+ assert_that(p.cargo_process("doc"),
+ execs().with_status(0));
+ assert_that(&p.root().join("target/doc/foo/index.html"), existing_file());
+});